package br.org.etec.dotcao.model;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public class Picture extends AbstractEntity {

	private static final long serialVersionUID = 1L;
	
	@Column
	private String path;

	@Column
	private int resolution;
	
	public String getPath() {
		return path;
	}
	
	public void setPath(String path) {
		if(path == null || path.isEmpty()){
			return;
		}
		
		this.path = "";
		
		Pattern pattern = Pattern.compile("\\\\");
		Matcher matcher = pattern.matcher(path);
		
		int start = 0;
		
		while(matcher.find(start)){
			this.path += path.substring(start, matcher.start()) + "/";
			start = matcher.end();
		}
		
		this.path += path.substring(start);
		
		System.out.println(this.path);
	}

	public int getResolution() {
		return resolution;
	}

	public void setResolution(int resolution) {
		this.resolution = resolution;
	}
	
}
